/*
 ----------------------------------------------------------------------------------
                           "THE BEER-WARE COPYRIGHT LICENSE"
                                     (Revision 43)
                                      -----------
    Rymek [rymek@rymek.org] wrote this file. As long as You retain this notice and
    this file has been sent directly to You by the author, You can do whatever You
    want with this stuff as long as You don't sell or rent it. If we meet some day,
    and You think this stuff is worth it, You can buy me a beer in return :-)
                                                                 __________
                                                                 Paweł Rymaszewski
  ----------------------------------------------------------------------------------
 */

package ui.windows.forms.serverForm;

import constants.UiConstants;
import ui.windows.components.panels.serverInformationPanel.ServerInformationPanel;
import utils.properties.Configuration;

import javax.swing.*;

/**
 * Window for choosing Database Server
 *
 * @author rymek
 *         User: Rymek
 *         Date: 20.07.11
 *         Time: 19:40
 */
public class ServerForm {

    private JPanel serverWindow;
    private ServerInformationPanel serverInformationPanel;
    private JButton connectButton;
    private JCheckBox saveDetailsCheckBox;
    private JCheckBox productionMode;

    private JFrame serverFrame;

    /**
     * Constructor/
     */
    public ServerForm() {

        ServerFormActionListener serverFormActionListener = new ServerFormActionListener(this);
        this.connectButton.addActionListener(serverFormActionListener);
        this.serverInformationPanel.setParentFrame(this);
    }

    /**
     * Creates ServerForm
     */
    public void createServerForm() {
        this.serverFrame = new JFrame(UiConstants.WND_SERVER_NAME + UiConstants.APP_WND_TITLE);
        this.serverFrame.setIconImage(Configuration.ICON_DEFAULT_FRAME);
        this.serverFrame.setContentPane(this.serverWindow);
        this.serverFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        this.serverFrame.setResizable(false);
        this.serverFrame.pack();
        this.serverFrame.setVisible(true);
    }

    /**
     * Custom initialization of some of the components
     */
    private void createUIComponents() {

        this.connectButton = new JButton(Configuration.ICON_CONNECT);
    }

    public ServerInformationPanel getServerInformationPanel() {
        return this.serverInformationPanel;
    }

    public void minimizeFrame() {
        this.serverFrame.setState(JFrame.ICONIFIED);
        this.serverFrame.pack();
    }

    public JCheckBox getSaveDetailsCheckBox() {
        return this.saveDetailsCheckBox;
    }

    public JCheckBox getProductionMode() {
        return this.productionMode;
    }

    public JButton getConnectButton() {
        return this.connectButton;
    }


}
